<?php
// +----------------------------------------------------------------------
// | 志进科技
// +----------------------------------------------------------------------
// | 官方网站: http://www.zhijin101.com
// +----------------------------------------------------------------------
// | Author: 张亚伟 <1743325520@qq.com>
// +----------------------------------------------------------------------

namespace Api\Controller;
/**
 * 签到奖品
 */
class PrizesController extends ApiController
{
    protected $noCheck = [];

    function _initialize() {
        parent::_initialize();
    }

    /**
     * 点赞
     */
    public function like()
    {
        $id = I('id');
        $res = like_log($this->uid, 4, $id);
        if($res['status']){
            $this->ajaxReturn(['s'=>true, 'm'=>'点赞成功']);
        }else{
            $this->ajaxReturn(['s'=>false, 'm'=>$res['msg']]);
        }

        $id = I('id');
        $info = M('prizes')->where(['id'=>$id])->find();
        if(empty($info)){
            $this->ajaxReturn(['s'=>false, 'm'=>'奖品不存在']);
        }
        $res = M('prizes')->where(['id'=>$id])->setInc('like_num', 1);
        if($res){
            $this->ajaxReturn(['s'=>true, 'm'=>'点赞成功']);
        }else{
            $this->ajaxReturn(['s'=>false, 'm'=>'点赞失败']);
        }
    }
}